﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1


{

    class Program
    {
        
        static void Main(string[] args)
        {
            int[] arr = { 11, 14, 21, 31, 34, 64 };
            Console.WriteLine("数组为：");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i]+"  ");
            }
            Console.WriteLine();
            float avg=0;
            int max=0;
            int min=0;
            int sum = GetIntResult(arr, ref avg, ref max,ref min);
            Console.WriteLine("sum={0},avg={1},max={2},min={3}", sum, avg, max, min);
            Console.Read();

            double[] nums = { 11.2, 12.4, 13.7, 28.9 };
            double max2, min2, avg2;
            GetValues(nums,out max2,out min2,out avg2);
            Console.WriteLine("sum={0},avg={1},max={2},min={3}", sum, avg, max, min);
            Console.Read();
        }
        static int GetIntResult(int []arr,ref float avg,ref int max,ref int min)
        {
            int sum = 0;
            max = arr[0];
            min = arr[0];
            for (int i = 0; i < arr.Length; i++)
            {
                sum += arr[i];

                if (max<arr[i])
                {
                    max = arr[i];
                }
                if (min>arr[i])
                {
                    min = arr[i];
                }
            }
            avg = sum / arr.Length;
            return sum;
        }
        static int GetValues(double[] nums, out double max2, out double min2, out double avg2)
        {
            double sum2 = 0;
            min2 = nums[0];
            max2 = nums[0];

            for (int i = 0; i < nums.Length; i++)
            {
                sum2 += nums[i];

                if (max2<nums[i])
                {
                    max2 = nums[i];
                }
                if (min2>nums[i])
                {
                    min2 = nums[i];
                }
            }
            avg2 = sum2 / nums.Length;
        }

    }
}
